<template>
	<view class="list-container">
		<view class="newlist">
			<newList
			:list="list"
			imgField="activity_banner"
			titleField="activity_name"
			@handleClick="gohref"
			></newList>
		</view>
	</view>
</template>

<script>
	import newList from "../../components/new_list/index.vue";
	import {getActivity} from "../../static/js/api/plan.js";
	export default{
		components:{
			newList
		},
		data(){
			return{
				list:[
					{
						img_url:"https://qiniu.aobeitineng.com/15b565e4-2733-42b1-a035-7e6e5927f83a.jpg",
						title:"北体·奥北第一届线上体能运动会",
						tips:"限时免费报名参赛",
					}
				], 
			}
		},
		onLoad(option) {
			console.log(option)
			if(option.type==1){
				uni.setNavigationBarTitle({
					title:"校园动态"
				})
			}else if(option.type==2){
				uni.setNavigationBarTitle({
					title:"校园活动"
				})
			}else if(option.type==3){
				uni.setNavigationBarTitle({
					title:"教育讲坛"
				})
			}else if(option.type==4){
				uni.setNavigationBarTitle({
					title:"示范教学"
				})
			}
			if(option.type){
				this.getData(option.type,option.schoolId)
			}
		},
		methods:{
			getData(type,schoolId){
				getActivity({
					type:type,
					school_id:schoolId,
				}).then(res=>{
					console.log(res)
					// if(res.activities){
					// 	res.activities.forEach(item=>{
					// 		item.tips = '作者 '+item.author
					// 	})
					// }
					this.list = res.activities
				})
			},
			gohref(item){
				uni.navigateTo({
					url:"/pages/campus/listDetails?activity_id="+ item.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.list-container{
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		.newlist{
			background-color: #fff;
		}
	}
</style>